/**
 * sfzh 身份证号码
 * bjSwitch 是否加载部级标签开关 ，1：加载, 空或其他：不加载
 * sdLocalSwitch 是否加载本地标签开关 ， 1：加载, 空或其他：不加载
 */
function laodTags(sfzh,bjSwitch,sdLocalSwitch){
    //判断加载条件
    if(sfzh==null || sfzh=='' || sfzh==undefined){
        console.log("加载标签失败，证件号码不能为空")
        return ;
    }

    //加载部标签
    if(bjSwitch==1){
        var param = new Object();
        param.sfzh = sfzh;
        $.ajax({
            url: path+"/bqms/sd/loadBjBq",
            type: "GET",
            data:param,
            success: function (result) {
                var success=result.success;
                if(success==true){
                    var bqhtml = '';
                    var ryzjh = result.sfzh;
                    var rybs_div="rybq_"+ryzjh;
                    var cont = result.content;
                    if(cont){
                        $.each(cont,function (m,BqObj) {
                            var rybs = switchNull(BqObj.rybs);
                            var rylb = switchNull(BqObj.rylb);
                            var bsqc = switchNull(BqObj.bsqc);
                            bqhtml += '<span class="biaoqianlb">'+rybs+'</span>';
                        });
                        //   $("."+rybs_div).empty();
                        $("."+rybs_div).html(bqhtml);
                    }
                }else{
                    console.error('获取数据错误')
                }
            },
            error: function (XmlHttpRequest, textStatus, errorThrown) {
                console.log("系统异常");
            }
        });
    }

    //加载本地标签
    if(sdLocalSwitch==1){
        $.ajax({
            url: path + "/bqms/sd/loadBqmsSdDataList?zjhm=" + sfzh,
            type: "GET",
            success: function (result) {
                if (result.success) {
                    var cont = result.content.list;
                    var ptl = '';
                    tagboxcont[i] = cont;
                    cont.map(function (m, n) {
                        ptl += "<span index='" + i + "' childindex='" + n + "' class='tagspan' onclick='openTagWin(this)'>" + m.mssx + "</span>";
                    })
                    $('.tags_' + item).html(ptl);
                } else {
                    console.error('获取数据错误')
                }
            },
            error: function (XmlHttpRequest, textStatus, errorThrown) {
                console.log("系统异常");
            }
        });
    }

}

/**
 * 本地标签弹窗框
 * */
function openTagWin(btn) {
    var index1=Number($(btn).attr('index'));
    var index2=Number($(btn).attr('childindex'));
    var data = tagboxcont[index1][index2] ;
    console.log(data);
    var params = new Object();
    params.zjhm = data.zjhm;
    params.mssxid = data.mssxid;
    var mssxurl = path + "/bqms/sd/loadJcmpBqmsSdDataListAll";
    $.ajax({
        url: mssxurl,
        data : params,
        contentType : 'application/json',
        type: "get",
        success: function (result) {
            if (result.success) {
                var cont = result.content.list;
                var html = '';
                html += '<div class="scroll-tag">';
                var ptl = '';
                cont.map(function (m, n) {
                    html += '	<div class="tag-div">';
                    html += '		<table class="tag-table">';
                    html += '			<tr>';
                    html += '				<th>标签项</th>';
                    html += '				<td>'+m.mssx+'</td>';
                    html += '				<th>详细描述</th>';
                    html += '				<td>'+m.msxx+'</td>';
                    html += '				<th>信息来源</th>';
                    html += '				<td>'+m.ly+'</td>';
                    html += '			</tr>';
                    html += '			<tr>';
                    html += '				<th>备注</th>';
                    html += '				<td colspan="5">'+m.memo+'</td>';
                    html += '			</tr>';
                    html += '		</table>';
                    html += '	</div>';
                });
                html += '</div>';

                layer.open({
                    type: 1,
                    // skin:'layui-layer-rim',
                    closeBtn: 1,
                    shade: 0.2,
                    title: ['标签详情', 'font-size:16px;font-weight:bold;color:#32A7EB;'],
                    fix: false,
                    area: ['800px', '500px'],
                    content: html
                });
            } else {
                console.error('获取数据错误')
            }
        },
        error: function (XmlHttpRequest, textStatus, errorThrown) {
            console.log("系统异常");
        }
    });
};


/**
 * 人员头像进行打标（多个）
 * 使用说明：需提供参数param对象，包含zjh（人员证件号）、xm（人员姓名）
 */
function loadRyBsNew(sfzh,xm) {
    //先将div元素插入，然后在往div中填充各类标识
    if (sfzh != undefined) {
        var zjh = "";
        var ryzjh = sfzh;
        var ctx = $("#ctx").val();
        if (ctx == undefined) {
            ctx = path;
        }
        var params = new Object();
        //1.人员标识
        var rybs_div = "rybs_" + ryzjh;
        var dzda_rybs_div = "dzda_rybs_" + ryzjh;
        //+++
        //1.跟盯、可疑、重点
        var u = ctx + "/jbxx/jbxxAliasData?zjh=" + ryzjh;
        jQuery.ajax({
            url: u,
            type: "post",
            data: params,
            success: function (data) {
                var ryzjh = data.content.zjh;
                var mark = data.content;
                var rybz = "";
                var lktb = "";
                //1.人员标识
                if (mark != undefined && mark != "null") {
                    var kyry = mark.kyry != undefined ? mark.kyry : "";//可疑人员
                    var zddqry = mark.zddqry != undefined ? mark.zddqry : "";//重点地区人员
                    var sfgdry = mark.sfgdry != undefined ? mark.sfgdry : "";//是否跟盯人员
                    var rylb = mark.rylb != undefined ? mark.rylb : "";//人员类别
                    var sxqk = mark.sxqk != undefined ? mark.sxqk : "";//视讯人员
                    var qwgjqk = mark.qwgjqk != undefined ? mark.qwgjqk : "";//前往过其他国家
                    var wghjqk = mark.wghjqk != undefined ? mark.wghjqk : "";//取得过国外户籍
                    var lkjb = mark.lkjb != undefined ? mark.lkjb : "";//列控级别
                    var skxs = mark.skxs != undefined ? mark.skxs : "";//涉恐系数
                    var qf = mark.qf != undefined ? mark.qf : "";//

                    if (kyry == '1') {
                        rybz += "<img src='" + ctx + "/static/images/sdrybs/kyry.png' width='15px' height='12px' style='cursor:pointer;margin-top: 9px;' title='可疑人员'/>";
                    }
                    if (zddqry == '1') {
                        rybz += "<img src='" + ctx + "/static/images/sdrybs/zddqry.png' width='15px' height='12px' style='cursor:pointer;margin-top: 9px;' title='重点地区人员'/>";
                    }
                    if (sfgdry > 0) {
                        rybz += "<img src='" + ctx + "/static/images/sdrybs/gd_red.png' width='15px' height='12px' style='cursor:pointer;margin-top: 9px;' title='跟盯人员'/>";
                    }
                    if (sxqk > 0) {
                        rybz += "<img src='" + ctx + "/static/images/sdrybs/sxqk.png' width='15px' height='12px' style='cursor:pointer;margin-top: 9px;' title='视询人员'/>";
                    }
                    if (qwgjqk > 0) {
                        rybz += "<img src='" + ctx + "/static/images/sdrybs/qwgjqk.png' width='15px' height='12px' style='cursor:pointer;margin-top: 9px;' title='前往过其他国家'/>";
                    }
                    if (wghjqk > 0) {
                        rybz += "<img src='" + ctx + "/static/images/sdrybs/wghjqk.png' width='15px' height='12px' style='cursor:pointer;margin-top: 9px;' title='取得国外户籍'/>";
                    }
                    if (qf != "") {
                        if (qf.indexOf("1") > -1) {
                            rybz += "<img src='" + ctx + "/static/images/sdrybs/rylb_btn/icon-1jzdr.png' width='15px' height='12px' style='cursor:pointer;margin-top: 9px;' title='一级重点人'/>";
                        }
                        if (qf.indexOf("2") > -1) {
                            rybz += "<img src='" + ctx + "/static/images/sdrybs/rylb_btn/icon-2jzdr.png' width='15px' height='12px' style='cursor:pointer;margin-top: 9px;' title='二级重点人'/>";
                        }
                        if (qf.indexOf("3") > -1) {
                            rybz += "<img src='" + ctx + "/static/images/sdrybs/rylb_btn/icon-3jzdr.png' width='15px' height='12px' style='cursor:pointer;margin-top: 9px;' title='三级重点人'/>";
                        }
                        if (qf.indexOf("4") > -1) {
                            rybz += "<img src='" + ctx + "/static/images/sdrybs/rylb_btn/icon-zdgzr.png' width='15px' height='12px' style='cursor:pointer;margin-top: 9px;' title='重点关注人'/>";
                        }
                        if (qf.indexOf("5") > -1) {
                            rybz += "<img src='" + ctx + "/static/images/sdrybs/rylb_btn/icon-gzrk.png' width='15px' height='12px' style='cursor:pointer;margin-top: 9px;' title='关注人'/>";
                        }
                        if (qf.indexOf("6") > -1) {
                            rybz += "<img src='" + ctx + "/static/images/sdrybs/rylb_btn/icon-lkrk.png' width='15px' height='12px' style='cursor:pointer;margin-top: 9px;' title='列控人'/>";
                        }
                        if (qf.indexOf("7") > -1) {
                            rybz += "<img src='" + ctx + "/static/images/sdrybs/rylb_btn/icon-zzdry.png' width='15px' height='12px' style='cursor:pointer;margin-top: 9px;' title='准重点人'/>";
                        }
                        if (qf.indexOf("98") > -1) {
                            rybz += "<img src='" + ctx + "/static/images/sdrybs/rylb_btn/icon-czrk.png' width='15px' height='12px' style='cursor:pointer;margin-top: 9px;' title='常口'/>";
                        }
                        if (qf.indexOf("99") > -1) {
                            rybz += "<img src='" + ctx + "/static/images/sdrybs/rylb_btn/icon-ldrk.png' width='15px' height='12px' style='cursor:pointer;margin-top: 9px;' title='流口'/>";
                        }

                    }
                    if (lkjb != undefined && lkjb != "") {
                        if (lkjb == "一级") {
                            lktb = "	<div class='com_lkjb_icon1'></div>";
                        } else if (lkjb == "二级") {
                            lktb = "	<div class='com_lkjb_icon2'></div>";
                        } else if (lkjb == "三级") {
                            lktb = "	<div class='com_lkjb_icon3'></div>";
                        }
                    }
                    if (rylb.length > 0) {
                        var rylb_arr = rylb.split(",");
                        var rylbMap = {
                            "15": ctx + "/static/images/sdrybs/rylb_btn/rylb_btn_15.png",
                            "14": ctx + "/static/images/sdrybs/rylb_btn/rylb_btn_14.png",
                            "13": ctx + "/static/images/sdrybs/rylb_btn/rylb_btn_13.png",
                            "12": ctx + "/static/images/sdrybs/rylb_btn/rylb_btn_12.png",
                            "11": ctx + "/static/images/sdrybs/rylb_btn/rylb_btn_11.png",
                            "10": ctx + "/static/images/sdrybs/rylb_btn/rylb_btn_10.png",
                            "9": ctx + "/static/images/sdrybs/rylb_btn/rylb_btn_09.png",
                            "8": ctx + "/static/images/sdrybs/rylb_btn/rylb_btn_08.png",
                            "7": ctx + "/static/images/sdrybs/rylb_btn/rylb_btn_07.png",
                            "6": ctx + "/static/images/sdrybs/rylb_btn/rylb_btn_06.png",
                            "5": ctx + "/static/images/sdrybs/rylb_btn/rylb_btn_05.png",
                            "4": ctx + "/static/images/sdrybs/rylb_btn/rylb_btn_04.png",
                            "3": ctx + "/static/images/sdrybs/rylb_btn/rylb_btn_03.png",
                            "2": ctx + "/static/images/sdrybs/rylb_btn/rylb_btn_02.png",
                            "1": ctx + "/static/images/sdrybs/rylb_btn/rylb_btn_01.png",
                        };
                        for (var k = 0; k < rylb_arr.length; k++) {
                            var k_rylb = rylb_arr[k];
                            if (k_rylb != undefined) {
                                rybz += "<img src='" + rylbMap[k_rylb] + "' width='13px' height='13px' style='margin-left:2px;margin-top:9px;'/>";
                            }
                        }
                    }
                    //涉恐系数
                    /*if(skxs!=undefined&&skxs.length>0){
                        rybz+="<font size='1' color='red' style='float:right;font-weight: bold;margin-right: 10px;'>"+skxs+"</font>";
                    }*/
                }

                var dic_content = "";
                dic_content += "	<div class='com_tup_div'><img src='" + url2 + (!isNull(ryzjh) ? ryzjh : ryzjh) + "&i=" + Math.random() + "'/></div>";
                dic_content += lktb;
                dic_content += "	<div class='com_xm_div'>" + xm + "</div>";
                dic_content += "	<div class='com_flbs_div'>" + rybz + "</div>";
               $(".rybs_" + ryzjh).html(dic_content);
            }
        });
    } else {
        var ryxm = xm;
        var ryzjh = sfzh;
        var rybs_div = "rybs_" + ryzjh;
        var dic_content = "";
        dic_content += "	<div class='com_tup_div'><img src='" + url2 + ryzjh + "'/></div>";
        dic_content += "	<div class='com_xm_div'>" + ryxm + "</div>";
        dic_content += "	<div class='com_flbs_div'></div>";
        $(".rybs_" + ryzjh).html(dic_content);
    }
}

